
#if !defined(AFX_REGISTRYRW_H__83156B9A_72B8_4B5E_BED4_755A85BEA548__INCLUDED_)
#define AFX_REGISTRYRW_H__83156B9A_72B8_4B5E_BED4_755A85BEA548__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afxwin.h>
#include <strsafe.h>

class CRegistryRW
{
public:
	CRegistryRW(void);
	~CRegistryRW(void);

public:
	//	static CNatePref * ms_pSingleton;

	// Registry
	void SetSharedPref(LPCTSTR szSharedPrefName, LPCTSTR szValue, 
		LPCTSTR szSectionName = _T("Settings"), BOOL bEncrypt = FALSE);

	CString GetSharedPref(LPCTSTR szSharedPrefName, LPCTSTR szSectionName = _T("Settings"),
		BOOL bEncrypted = FALSE);

	BOOL GetSharedPref(LPCTSTR szSharedPrefName, LPTSTR szBuff, int * pcbBuffSize, 
		LPCTSTR szSectionName = _T("Settings"), BOOL bEncrypted = FALSE);

	//////////////////////////////////////////////////////
	void DeleteRegistryKey( LPCTSTR szCompany, LPCTSTR szAppName, LPCTSTR szSection,
		LPCTSTR szDataName);

	void SetAppName(CString strAppName);
	void SetOwnerCmn(CString strCmn);
private:

	CString ReadRegistryStr(LPCTSTR szCompany, LPCTSTR szAppName, LPCTSTR szSection,
		LPCTSTR szDataName, int nMaxSize, BOOL bBinary);

	BOOL ReadRegistryStr( LPCTSTR szCompany, LPCTSTR szAppName, LPCTSTR szSection,
		LPCTSTR szDataName, LPBYTE szBuff, int * pcbBuffSize, BOOL bBinary = FALSE );

	void WriteRegistryStr( LPCTSTR szCompany, LPCTSTR szAppName, LPCTSTR szSection,
		LPCTSTR szDataName, LPBYTE szDataValue, BOOL bBinary = FALSE, int nSize = -1 );

	CString GetUserKey(BOOL bIsEncode =FALSE);
protected:
	CString m_strAppName;
	CString m_strOwnerCmn;
	CString m_strEncodedUserKey;
};


#endif // !defined(AFX_UTIL_H__83156B9A_72B8_4B5E_BED4_755A85BEA548__INCLUDED_)